/**
 * 新闻列表
 */
SearchNews = Ext.extend(Ext.Panel, {
	constructor : function(_cfg) {
		Ext.applyIf(this, _cfg);
		this.initUIComponents();
		SearchNews.superclass.constructor.call(this, {
					id : 'SearchNews',
					title : '全部公告',
					region : 'center',
					layout : 'border',
					items : [this.searchPanel, this.gridPanel]
				});
	},// end of constructor
	initUIComponents : function() {
		var me = this;
		this.searchPanel = new KE.SearchPanel({
					region : 'north',
					items : [{
								text : '新闻内容:'
							}, {
								xtype : 'textfield',
								name : 'Q_LIKES_content',
								width : 250
							}, {
								xtype : 'button',
								text : '查询',
								scope : this,
								iconCls : 'btn-search',
								handler : this.search
							}, {
								xtype : 'button',
								text : '清空',
								scope : this,
								iconCls : 'reset',
								handler : this.reset
								}]
				});// end of searchPanel
		this.topbar = new Ext.Toolbar({
			items : [{
						iconCls : 'btn-refresh',
						text : '刷新',
						xtype : 'button',
						scope : this,
						handler : function() {
							this.gridPanel.getStore().load();
						}
					}]
		});
		this.gridPanel = new KE.GridPanel({
			region : 'center',
			id: 'SearchNewsGrid',
			tbar : this.topbar,
			url : __ctxPath + '/zfjc/myNewsMyWork.do?isNotice=1',
			fields : ['newsId','sectionId', 'subjectIcon', 'subject',
					'author', 'createtime', 'expTime',
					'replyCounts', 'viewCounts', 'issuer',
					'content', 'updateTime', 'status',
					'isDeskImage', 'isNotice', 'sn'],
			columns : [{
							header : 'newsId',
							dataIndex : 'newsId',
							hidden : true
						}, {
							header : '新闻标题',
							width : 120,
							dataIndex : 'subject'
						}, {
							header : '发布者',
							width : 120,
							dataIndex : 'issuer'
						}, {
							header : '创建时间',
							dataIndex : 'createtime',
							renderer : function(value) {
								if (value != null) {
									return value.substring(0, 10);
								}
							}
						}, {
							header : '回复次数',
							width : 120,
							dataIndex : 'replyCounts'
						}, {
							header : '浏览数',
							width : 120,
							dataIndex : 'viewCounts'
						}, {
							header : '状态',
							width : 120,
							dataIndex : 'status',
							renderer : function(value) {
								if (value != null && value == 0) {
									return '<font color="red">禁用</font>';
								} else if (value == 1) {
									return '<font color="green">激活</font>';
								}
							}
						}]
		});
		this.gridPanel.addListener('rowdblclick', this.rowClick);
	},
	// 重置查询表单
	reset : function() {
		this.searchPanel.getForm().reset();
	},
	// 按条件搜索
	search : function() {
		$search({
					searchPanel : this.searchPanel,
					gridPanel : this.gridPanel
				});
	},
	rowClick : function(grid, rec) {
		App.clickTopTab('NewsDetail', rec.data.newsId,
				function() {
					//AppUtil.removeTab('NewsDetail');
				});
	}
	
});
